	//index.js
    const Generator = require('yeoman-generator')
    module.exports = class extends Generator {
        // 命令行交互方式获取数据
        prompting(){
            return this.prompt([
                {
                    type: 'input',
                    name: 'name',
                    mesage: 'Your project name',
                    default: this.appname
                }
            ]).then(answers => {
                this.answers = answers
            })
        }
        
        writing(){
            // 把每一个文件通过模板转换到目标路径
            const templates = [ //目标相对路径数组
              '.browserslistrc',
              '.editorconfig',
              '.env.development',
              '.env.production',
              '.eslintrc.js',
              '.gitignore',
              'babel.config.js',
              'package.json',
              'postcss.config.js',
              'README.md',
              'public/favicon.ico',
              'public/index.html',
              'src/App.vue',
              'src/main.js',
              'src/router.js',
              'src/assets/logo.png',
              'src/components/HelloWorld.vue',
              'src/store/actions.js',
              'src/store/getters.js',
              'src/store/index.js',
              'src/store/mutations.js',
              'src/store/state.js',
              'src/utils/request.js',
              'src/views/About.vue',
              'src/views/Home.vue'
            ]
            
            templates.forEach(item => {
                // item => 每个文件路径
                this.fs.copyTpl(
                  this.templatePath(item),
                  this.destinationPath(item),
                  this.answers
                )
            })
        }
    }
    